package com.andnux.android.adapter;

import com.andnux.android.data.Works;
import com.andnux.android.databinding.ItemWorksUserBinding;
import com.andnux.android.network.GsonUtils;
import com.andnux.android.utils.ImageLoader;
import com.google.gson.reflect.TypeToken;

import java.util.List;

public class UserWorksAdapter extends BaseAdapter<Works, ItemWorksUserBinding> {

    @Override
    public void onBindView(ItemWorksUserBinding binding, Works works, int position) {
        super.onBindView(binding, works, position);
        String json = works.getFiles();
        List<String> files = GsonUtils.gson.fromJson(json, new TypeToken<List<String>>() {
        }.getType());
        ImageLoader.load(files.get(0), binding.imageView);
        binding.title.setText(works.getTitle());
    }
}
